﻿#include<iostream>
using namespace std;
const int N = 100010;

int n, m;
int a[N], s[N];
int main() 
{
	cin >> n >> m;				//n=5  m=3
	for (int i = 1; i <= n; i++)
		cin >> a[i];			//2 1 3 6 4
	for (int i = 1; i <= n; i++)
		s[i] = s[i - 1] + a[i]; //s[1]=s[0]+a[1]=0+2=2
								//s[2]=s[1]+a[2]=2+1=3
								//s[3]=s[2]+a[3]=3+3=6
								//s[4]=s[3]+a[4]=6+6=12
								//s[5]=s[4]+a[5]=12+4=16
	while (m--)
	{
		int l, r;				
		cin >> l >> r;			
		cout << s[r] - s[l - 1];//l=1 r=2 s[2]-s[0]=3
		cout << endl;			//l=1 r=3 s[3]-s[0]=6
	}							//l=2 r=4 s[4]-s[1]=10
	system("pause");
	return 0;
};